const qiniu = require('qiniu');
const formidable = require('formidable');
const fs = require('fs');
const config = {};
config.accessKey = 'VPHedAs_21doaPZVk4VGlXavhp_HDp0jYGIT9CFA'; //七牛云Ak密匙
config.secretKey = 'QFp2gPoepb_Dm0Cn8qnldYlXxlNUvPawNFfebTTz'; //七牛云Sk密匙
config.bucket = 'lift-ad'; //存储空间的名字
config.url = 's9lsmvvn5.hn-bkt.clouddn.com'; //配置的域名
const qn = {}
//构建上传策略函数 （获取七牛上传token）
qn.uptoken = function(bucket) {
    const putPolicy = new qiniu.rs.PutPolicy({ scope: config.bucket });
    const accessKey = config.accessKey;
    const secretKey = config.secretKey;
    const mac = new qiniu.auth.digest.Mac(accessKey, secretKey);
    const uploadToken=putPolicy.uploadToken(mac);
    return uploadToken;
}
     
module.exports = qn;
